package cn.snmp.mutual.util;
import cn.snmp.mutual.common.tools.XmlFile;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.snmp.mutual.data.ObjService;
import cn.snmp.mutual.data.XmlService;

/**
 * @author dengkn
 * */
@Slf4j
public class MibNodeDataUtils {
	

	public static ObjService getMibTable(ObjService osParams) {
		ObjService osRootNode = null;
		String strConfigFile = osParams.getStringValue("ConfigFile");
		XmlService strMibProfile = getXmlFile(strConfigFile);
		osRootNode = XmlService.xmlService2ObjService(strMibProfile);
		osParams.addContainedObject(osRootNode);
		return osParams;
	}

	public static XmlService getXmlFile(String xmlFileName) {
		try {
			XmlFile e = new XmlFile(xmlFileName);
			XmlService xmlService = e.node2XmlService(e.getRootNode());
			return xmlService;
		} catch (Exception e) {
			log.error("xml File init error! " + e);
			return null;
		}
	}
}
